<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>个人资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../../plugins/layui/css/layui.css" media="all" />
</head>

<body>
    <script src="../../plugins/jquery.min.js"></script>
    <script src="../../js/javascript.util.js"></script>
    <script src="../../js/jquery.util.js"></script>
    <script src="../../plugins/layui/layui.js"></script>
    <script>
        layui.use(['laytpl'], function () {
            var laytpl = layui.laytpl;

            var obj = {
                type: 'get'
                , url: "../../services/data/getUserInfo.json"
                , data: '{}'
                , dataType: 'json'
                , success: function (result) {
                    if (result.code === 200) {
                        var getTpl = demo.innerHTML
                            , view = document.getElementById('view');
                        laytpl(getTpl).render(result.data[0], function (html) {
                            view.innerHTML = html;
                        });
                    } else {
                        layer.msg('获取用户信息失败。');
                        console.warn(result.msg);
                    }
                }
                , error: function (ex) {
                    console.warn(ex.responseText);
                }
            };

            //jquery ajax请求
            jqueryAjax(obj);
        });
    </script>

    <div id="view"></div>

    <script id="demo" type="text/html">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>账户信息</legend>
        </fieldset>
        <table class="layui-table">
            <colgroup>
                <col width="100">
                <col>
                <col width="100">
                <col>
            </colgroup>
            <thead style="display:none" hidden="hidden">
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>4</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><strong>用户账号:</strong></td>
                    <td>{{d.user_acc}}</td>
                    <td><strong>创建日期:</strong></td>
                    <td>{{ d.create_time.replace('T',' ')}} </td>
                </tr>
                <tr>
                    <td><strong>创建人:</strong></td>
                    <td>{{d.create_user}}</td>
                    <td><strong>是否锁定:</strong></td>
                    <td>{{ d.is_lock==0? '是':'否' }}</td>
                </tr>
                <tr>
                    <td><strong>所属角色:</strong></td>
                    <td colspan="3">
                            {{# if(d.roleNames){layui.each(d.roleNames, function(index, item){ }}
                            {{item}}
                            &nbsp;&nbsp;&nbsp;
                            {{# });} }}
                    </td>
                </tr>
            </tbody>
        </table>

        <br />

        <fieldset class="layui-elem-field layui-field-title">
            <legend>个人信息</legend>
        </fieldset>
        <table class="layui-table">
            <colgroup>
                <col width="100">
                <col>
                <col width="100">
                <col>
            </colgroup>
            <thead style="display:none" hidden="hidden">
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>4</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><strong>用户名:</strong></td>
                    <td>{{d.user_name}}</td>
                    <td><strong>手机:</strong></td>
                    <td>{{d.mobile}}</td>
                </tr>
                <tr>
                    <td><strong>电话:</strong></td>
                    <td>{{d.tel_phone}}</td>
                    <td><strong>邮箱:</strong></td>
                    <td>{{d.e_mail}}</td>
                </tr>
            </tbody>
        </table>
        <fieldset class="layui-elem-field">
            <legend>当前头像</legend>
            <div class="layui-field-box">
                <img src="{{d.icon +'?shuijishu=' + Math.random() }}" alt="默认的头像" />
            </div>
        </fieldset>
    </script>
</body>

</html>